//
//  TextViewController.m
//  UI
//
//  Created by MAC on 15-11-9.
//  Copyright (c) 2015年 m. All rights reserved.
//

#import "TextViewController.h"
#import "ViewController.h"

@interface TextViewController ()
{
    NSArray * data;
    NSArray * detail;
}

@end

@implementation TextViewController



- (void)viewDidLoad
{
    data = @[
             
             @"姓名",
             @"电话号码" ,
             @"姓名",
             @"电话号码"
             
             
             ];
    detail = @[
              @"夏志龙",
              @"15699999999",
              @"杨开宇",
              @"12828282828"
              
              ];
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return data.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell * cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    
    cell.textLabel.text = data[indexPath.row];
    
    //----后缀
    cell.detailTextLabel.text = detail[indexPath.row];
    
    //----箭头
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    ViewController * con = [ViewController new];
    [self.navigationController pushViewController:con animated:YES];
}

-(BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    return YES;
}

-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath
{
}

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSMutableArray * arr = data.mutableCopy;
        [arr removeObjectAtIndex:indexPath.row];
        data = arr;
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
    }
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
